<html>
<head>
<title>TTempSmooth</title>
<link rel="stylesheet" type="text/css" href="../../avisynth.css">
<!--
Automatically generated, don't change:
$Id: ttempSmooth.htm,v 1.3 2012/07/03 07:44:18 ianb1957 Exp $ 
-->
</head>
<body>
<h1>TTempSmooth</h1>
<h2>Abstract</h2>
<b>author:</b>    tritical
<br><b>version:</b>        0.9.4<br>
<b>download:</b>   <a href="http://bengal.missouri.edu/~kes25c/">http://bengal.missouri.edu/~kes25c/</a>
<br><b>category:</b> Temporal Smoothers
<br><b>requirements:</b>&nbsp;
<ul>
  <li>YV12 &amp; YUY2 Colorspace</li>
</ul>

<p><b>license:</b> GPL</p>

<hr size=2 width="100%" align=center>

<!-- #EndTemplate -->
<h2>Description</h2>
<p>      TTempSmooth is a motion adaptive (it only works on stationary parts of the picture), temporal   smoothing filter.  TTempSmoothF is a faster (50-75%)
version of TTempSmooth that doesn't take the mdiff/mdiffC parameters (it is equivalent to running
TTempSmooth with mdiff/mdiffC set equal to or greater then LThresh-1/CThresh-1).</p>
<h3>Syntax</h3>
<p><code>TTempSmooth</code> (clip, int <var>&quot;maxr&quot;</var>, int <var>&quot;lthresh&quot;</var>, int <var>&quot;cthresh&quot;</var>,
int <var>&quot;lmdiff&quot;</var>, int <var>&quot;cmdiff&quot;</var>, int <var>&quot;strength&quot;</var>, float <var>&quot;scthresh&quot;</var>,
bool <var>&quot;fp&quot;</var>, int <var>&quot;vis_blur&quot;</var>, bool <var>&quot;debug&quot;</var>, bool <var>&quot;interlaced&quot;</var>, PClip <var>&quot;pfclip&quot;</var>)<br>
<br>
<code>TTempSmoothF</code> (clip, int <var>&quot;maxr&quot;</var>, int <var>&quot;lthresh&quot;</var>, int <var>&quot;cthresh&quot;</var>, float <var>&quot;scthresh&quot;</var>,
bool <var>&quot;fp&quot;</var>, int <var>&quot;vis_blur&quot;</var>, bool <var>&quot;debug&quot;</var>, bool <var>&quot;interlaced&quot;</var>, PClip <var>&quot;pfclip&quot;</var>)</p>
<h3>PARAMETERS</h3>
<p><var>   maxd</var> -  (maximum temporal diameter)</p>
<p>This sets the maximum temporal radius.  By the way it works TTempSmooth automatically varies the
      radius used... this sets the maximum boundary.  Possible values are 1 through 7.  At 1 TTempSmooth
      will be (at max) including pixels from 1 frame away in the average (3 frames total will be
      considered counting the current frame).  At 7 it would be including pixels from up to 7 frames 
      away (15 frames total will be considered).  With the way it checks motion there isn't much danger 
      in setting this high, it's basically a quality vs. speed option.  Lower settings are faster while 
      larger values tend to create a more stable image.</p>
<p>default = 3 (int)</p>
<p><var>LThresh</var>/<var>CThresh</var> - (luma and chroma thesholds)</p>
<p>Your standard luma and chroma thresholds for differences of pixels between frames.  lthresh is
      for luma and cthresh is for chroma. TTempSmooth checks 2 frame distance as well as single frame,
      so these can usually be set slightly higher than with most other temporal smoothers and still 
      avoid artifacts.  Valid settings are from 1 to 256.  Also important is the fact that as long as 
      "mdiff" is less than the threshold value then pixels with larger differences from the original 
      will have less weight in the average.  Thus, even with rather large thresholds pixels just under 
      the threshold wont have much weight, helping to reduce artifacts.</p>
<p>default - <var>LThresh</var> = 4  (int)<br>
<var>CThresh</var> = 5  (int)</p>
<p><var>lmdiff</var>/<var>cmdifC</var> - (maintain diff) - (only used in TTempSmooth not TTempSmoothF)</p>
<p>Any pixels with differences less than or equal to "mdiff" will be blurred at maximum.  Usually, 
      the larger the difference to the center pixel the smaller the weight in the average.  mdiff makes 
      TTempSmooth treat pixels that have a difference of less than or equal to "mdiff" as though they 
      have a difference of 0.  In other words, it shifts the zero difference point outwards. Set "mdiff" 
      to a value equal to or greater than lthresh-1/cthresh-1 to completely disable inverse pixel 
      difference weighting.  Valid settings are from 0 to 255. lmdiff is for luma and cmdiff is for
      chroma.</p>
<p>      default - <var>lmdiff</var> = 2  (int)<br>
<var>cmdiff</var> = 3 (int)</p>

<p>   <var>strength</var> - (spatial weighting factor)</p>

<p>      TTempSmooth uses inverse distance weighting when deciding how much weight to give to each
      pixel value.  The strength option lets you shift the drop off point away from the center to
      give a stronger smoothing effect and add weight to the outer pixels. It does for the spatial
      weights what mdiff does for the difference weights. The possible options are:<br>


          1 =    0.13 0.14 0.16 0.20 0.25 0.33 0.50 1.00 0.50 0.33 0.25 0.20 0.16 0.14 0.13<br>
          2 =    0.14 0.16 0.20 0.25 0.33 0.50 1.00 1.00 1.00 0.50 0.33 0.25 0.20 0.16 0.14<br>
          3 =    0.16 0.20 0.25 0.33 0.50 1.00 1.00 1.00 1.00 1.00 0.50 0.33 0.25 0.20 0.16<br>
          4 =    0.20 0.25 0.33 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50 0.33 0.25 0.20<br>
          5 =    0.25 0.33 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50 0.33 0.25<br>
          6 =    0.33 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50 0.33<br>
          7 =    0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50<br>
          8 =    1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00</p>


<p>      The values shown are for maxr = 7, when using smaller radius values the weights outside
      of the range are simply dropped.  Thus, setting strength to a value of maxr+1 or higher will 
      give you equal spatial weighting of all pixels in the kernel.  Versions prior to v0.9.3 always
      used weighting equal to strength = 2.</p>

      <p>default =  2 (int)</p>


<p>   <var>scthresh</var> - (scenechange threshold)

<p>      The standard scenechange threshold as a percentage of maximum possible change of the luma plane.
      A good range of values is between 8 and 15.  Use the debug output option to see what frames
      are detected as a scenechange and the difference value calculated for each frame.  Set scthresh
      to &lt;= 0.0 to disable scenechange detection.</p>

<p>      default =  12.0 (float)</p>

 
<p>   <var>fp</var> - (regular or fixed point average)</p>

<p>      Setting fp=true will add any weight not given to the outer pixels back onto the center pixel
      when computing the final value.  Setting fp=false will just do a normal weighted average.
      fp=true is much better for reducing artifacts in motion areas and usually produces overall 
      better results.</p>

<p>      default =  true (bool)</p>


<p>   <var>vis_blur</var> - (visualize blur)</p>

<p>       This option outputs a map that indicates which pixels are being filtered and by how much. For 
      each pixel it computes how much weight was given to the outer pixels (i.e. not the center pixel) 
      out of the maximum possible weight that could have been given to the outer pixels.  It then scales 
      this result into the 0 to 255 range so that in areas where no weight was given to the outer pixels 
      (no smoothing is taking place) it will show black, and in areas where all possible weight was 
      given to the outer pixels (maximum smoothing is taking place) it will show white.  In other words, 
      the darker the value the weaker the smoothing, the brighter the value the stronger the smoothing.  
      Possible values are:</p>

<p>          0 - no map<br>
          1 - map of Y plane smoothing<br>
          2 - map of U plane smoothing<br>
          3 - map of V plane smoothing

<p>      default =  0 (int)</p>


<p>   <var>debug</var> - (debug output)</p>

<p>      If enabled, TTempSmooth will output the scenechange statistics and indicate which frames were
      detected as scenechanges.  This is intended to help with tweaking scthresh.  To view the output
      you can use <a href=http://www.sysinternals.com/Utilities/DebugView.html><cite>"DebugView" from sysinternals.</cite></a></p>

<p>      default =  false (bool)</p>


<p>   <var>interlaced</var> - (interlaced yv12 input)</p>

<p>      Set this to true if you are using ttempsmooth on a YV12 interlaced clip... otherwise set it to
      false.  This setting only effects YV12 input and has no effect if the input is YUY2 because 
      interlaced YUY2 needs no special handling.

<p>      default =  false (bool)</p>


<p>   <var>pfclip</var> -  (pre-filtered clip to use for pixel differences)</p>

      This allows you to specify a separate clip for ttempsmooth to use when calculating
      pixel differences.  This applies to checking the motion thresholds, calculating 
      inverse difference weights, and detecting scenechanges.  Basically, the pfclip will
      be used to determine the weights in the average but the weights will be applied to
      the original input clip's pixel values.  This option is similar to "ppClip" in
      TBilateral... some possible suggestions for pre-filtering are a gaussian blur, adaptive
      median, etc...

<p>      default =  NULL (PClip)</p>


<h2>Changelog</h2>
<p>   11/17/2005  v0.9.4<br>

       + Added interlaced parameter (fix incorrect interlaced yv12 chroma handling)<br>
       + Added pfclip parameter<br>
       + Added MMX scenechange routines (for those that don't have an isse capable cpu)<br>
       - Changed default scthresh value to 12.0<br>

<p>   07/20/2005  v0.9.3<br>

       + Added scenechange detection<br>
       + Added visualize blur option<br>
       + Added back in fp and the ability to do a regular average (was removed in v0.9.1)<br>
       + Added debug output<br>
       + Added strength option to adjust spatial weights<br>
       + Rewrote all the code (vastly reduced the total source size)<br>
       + 10% speed increase for TTempSmooth()<br>
       - Changed to maxr instead of maxd, increased max possible radius value from 4 to 7 
             and decreased the min possible radius from 2 to 1<br>
       - Changed some of the parameter names (mdiff=lmdiff,mdiffc=cmdiff)<br>
       - Changed default lmdiff/cmdiff values to 2/3 (were 3/4)<br>


<p>   07/29/2004  v0.9.2<br>
       - Modified buffering code to remove unneeded BitBlts()... small speed up (5-10%).<br>
       - Request frames in linear order when completely refilling buffer.<br>
       - Added TTempSmoothF(), a faster version of TTempSmooth (50-75%), which is equivalent to using
TTempSmooth() with mdiff/mdiffC equal to or greater then LThresh/CThresh.  Thus, it only takes
maxd, LThresh, and CThresh as parameters.<br>
       - Changed defaults to be less aggressive.<br>
       - There were no quality changes, the same settings will produce the same output as in v0.9.1.</p>
<p>06/15/2004  v0.9.1<br>
       - Fixed a major bug that caused incorrect calculation of the chroma differences, rendering the
filter completely useless.<br>
       - Got rid of amount/amountC and fixedPoint parameters.  They were unneeded in the case of amount
and fixedPoint = true always worked better then false...<br>
       - Small speed up<br>
       - Changed some of the defaults.</p>
<p>06/11/2004  v0.9<br>
       - Initial Release</p>
<p><kbd>$Date: 2012/07/03 07:44:18 $</kbd>
</p>
</body>
</html>
